package com.cloud.rou.im.protocol.serialize;


import com.cloud.rou.im.core.util.ObjectNullUtil;

/**
 * <p></p>
 *
 * @author GaoShuangWen
 */
@BindAndEnableSerializer(name = SerializeTypeConstants.PROTO_STUFF)
public class ProtoStuffSerializer implements Serializer {

    private ProtoStuffSerializer(){}

    @Override
    public byte[] serialize(Object object) {
        ObjectNullUtil.notNull(object);
        return ProtoStuffSerializationUtil.serializeToByte(object);
    }

    @Override
    public <T> T deserialize(byte[] bytes, Class<T> clazz) {
        ObjectNullUtil.notNull(bytes);
        return ProtoStuffSerializationUtil.deserializeFromByte(bytes,clazz);
    }
}
